home *** CD-ROM | disk | FTP | other *** search
- ═════════════════════════════════════════════════════════════════════════════
- Module : FileBuff.Pas (Version 1.2)
- Written : 05/02/95
- Last Update : 05/13/95
-
- Provides simple file buffering for Delphi. It works only w/ binary
- files and treats that file as a stream of bytes. Basically it
- provides the same functionality as BlockWrite() and BlockRead on a
- Reset(f,1) untyped file. Also provided is a file BuffTest.Pas which
- is a visual test stub to compare times between unbuffered and the
- current unit. Since Borland in it's infinite wisdom decided to
- get rid of TBufStream in this release, here is a suitable
- replacement.
-
-
- Copyright (c) 1995 Opnek Research. All Rights Reserved.
- ═════════════════════════════════════════════════════════════════════════════
-
- IMPORTANT!!
- -----------
- Well, silly me...I uploaded a previous bug version. Damn that version
- control thing. Here is the corrected, non-buggy version. Please replace
- any pre-1.2 version of file buffer. If you don't want the test code,
- get rid of the {$_TESTHARNESS} define.
-
-
- Running the Demo
- ----------------
- I have included a project that encapsulates all this info.
- Create a new windows program, and add the TestBuff.pas, Assert.Pas,
- TestBuff.dfm and the FileBuff.pas. Then in your project, define the
- following two conditionals (_NDEBUG, and _TESTHARNESS). The first
- turns off assert checking and the second includes the test harness
- code in your compilation. The initial demo writes files of
- 31 x 200000 = 6 meg in length w/ a 32k buffer, so check your disk
- space first. It creates 4 of these files. So you must have 24 meg
- free before you run, or reduce the records written. This could take quite
- a while to run based on how many records you wish to read/right.
-
-
- Files
- -----
- FileBuff.pas - Contains the actual TBufferedFile object.
- Assert.pas - Module to do asserts, used by FileBuff.pas
- TestBuff.pas - Is the test pascal code that calls the testing proc.
- TestBuff.??? - Form contents for the test program.
-
-
- Distribution Rights
- -------------------
- I'm not quite sure how to group this software release. It's purpose
- is to promote the exchange of 'handy' modules between programmers to
- reduce the tedious task of re-creating the simple stuff. I'll call it
- "EasyWare" for lack of a better term. You may compile this module in
- any application you so chose. If you find it useful, simply register
- for $10 dollars (US). You DO NOT have to register to use this library
- in your compiled commercial applications. Registering simply gets you
- updates and tells the author thanks. The only restriction on the use
- of this module is that it may not be incorporated into a large source
- code commercial library. In otherwords, it's okay to use in your day
- to day and even compiled commercial applications, but you may not
- distribute the code for profit without written consent of the author.
- This prevents a person from gathering up all the "EasyWare" and
- selling a source library for a larger price tag. Registering the
- software will get you bug fixes and updates to the software. The
- copyright on the code will still belong to Opnek Research no matter what.
-
- I encourage other programmers that have other such libraries to also
- distribute your libs via the EasyWare name. Hopefully after a few
- months, we will have a high-quality low cost set of re-usuable tools.
- And all of our lifes will be a little easier. And hopefully help you
- recoup the time you invested in creating the library.
-
- I assume no liability whatsoever for your use or misuse of this unit.
- Any use of this unit, voids any warranty implied or otherwise. This
- code, although tested will most likely have at least one bug left in it.
-
-
- Usage
- -----
- Simply read the TestBuff.Pas file, it will explain how the
- TBufferedFile object is compatible w/ the Assign, Reset, Rewrite,
- BlockRead/Write procedures. It's actually pretty simple to implement
- and use.
-
-
- The Benefits
- ------------
- If you do alot of copying files, reformatting files or writes of very
- small records, the TBufferedFile object will save you a great deal of
- time.
-
-
- CreateFile Copy File Read File Modify File In Place
- +-----------+-----------+-----------+----------------------+
- Unbuffered | 56.52 | 122.50 | 44.49 | 118.30 |
- +-----------+-----------+-----------+----------------------+
- Buffered | 12.80 | 25.59 | 6.37 | 27.19 |
- +-----------+-----------+-----------+----------------------+
-
-
- All times are based on 31 byte records w/ a 32,676 buffer size and writing
- out 200,000 records. The times are in seconds.
-
- Just to give you a frame of reference. If I read a file of the above size
- at 64k bytes a shot, no other processing, it will take the system 4.51
- seconds to read the file. To write the file 64k at a time it takes 7.91
- seconds. That is with no processing other than looping and blockwriting
- 64k at a time. BTW, the test program allows you to change the parameters
- and see how much your application will benefit from file buffering. The
- larger your record size, the less file buffering will help.
-
-
- Contacting the Author
- ---------------------
- You can email me with bugs, problems, comments, questions, etc... at
- Compuserve [74002,2212] Jay Cole. If you would like to see some
- enhancements, please feel free to drop me a line, I'll see if I can add
- it.
-
- Registering the Software
- ------------------------
- Send $10US, Check or Money Order to :
-
- Jay Cole
- 809 Mooreland Drive
- Bowling Green, KY 42103
-
- Again, it is NOT required to register for you to use this product in your
- systems. Drop me an E-Mail if you find it useful.
-
-
- Final Notes
- -----------
- The module Asserts is included to provide Assert() capability that I have
- grown to like w/ C, C++. Unfortunately, no macro facility is available
- in Delphi, so I use the kludgy conditional compiles. Seems to work pretty
- well. If you wan't to know more about Asserts() read "Writing Solid Code"
- by Steven Maquire. Microsoft Press. An excellent book on bullet proofing
- your code. BTW, Asserts() is a totally free EasyWare module. No
- registration required.